package demo1;
import java.awt.FlowLayout;

import javax.swing.*;
public class TestFlowLayout {
	public static void main(String[] args) {
		//创建顶层容器
		JFrame jf = new JFrame();
		jf.setSize(300,400);
		//jf.setVisible(true);
		jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		jf.setLocationRelativeTo(null);
		jf.setResizable(false);
		jf.setTitle("这是标题");
		//创建中间容器
		JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
		
		//创建一个按钮
		JButton button1 = new JButton("按钮1");
		JButton button2 = new JButton("按钮2");
		JButton button3 = new JButton("按钮3");
		JButton button4 = new JButton("按钮4");
		JButton button5 = new JButton("按钮5");
		
		//将按钮添加到中间容器当中
		panel.add(button1);
		panel.add(button2);
		panel.add(button3);
		panel.add(button4);
		panel.add(button5);
		
		//将中间容器添加到顶层容器中
		jf.setContentPane(panel);
		jf.setVisible(true);
	}

}
